 package cn.east196.xproto.zero;

 import java.io.UnsupportedEncodingException;
 import java.nio.BufferOverflowException;

 public abstract class InputBuffer
 {
   protected byte[] buf = null;
   protected int pos = 0;
   protected int limit = 0;
 
   public InputBuffer(byte[] paramArrayOfByte) {
     this(paramArrayOfByte, 0, paramArrayOfByte.length);
   }
 
   public InputBuffer(byte[] paramArrayOfByte, int paramInt1, int paramInt2) {
     this.buf = paramArrayOfByte;
     this.pos = paramInt1;
     this.limit = (paramInt1 + paramInt2);
   }
 
   protected void checkLength(int paramInt) {
     if (this.pos + paramInt > this.limit) {
         throw new BufferOverflowException();
     }
   }
 
   public int getByteSigned()
   {
     checkLength(1);
     int i = this.buf[(this.pos++)];
     return i;
   }
 
   public int getByte() {
     return getByteSigned() & 0xFF;
   }
 
   public abstract int getInt16();
 
   public abstract int getInt16Signed();
 
   public abstract int getInt24();
 
   public abstract int getInt24Signed();
 
   public abstract int getInt32();
 
   public abstract int getInt32Signed();
 
   public int getRemainingLength() {
     return this.limit - this.pos;
   }
 
   public byte[] getByteArray(int paramInt) {
     checkLength(paramInt);
     byte[] arrayOfByte = new byte[paramInt];
     System.arraycopy(this.buf, this.pos, arrayOfByte, 0, paramInt);
     this.pos += paramInt;
     return arrayOfByte;
   }
 
   public String getString(int paramInt, String paramString) {
     checkLength(paramInt);
     byte[] arrayOfByte = new byte[paramInt];
     System.arraycopy(this.buf, this.pos, arrayOfByte, 0, paramInt);
     this.pos += paramInt;
     try
     {
       return new String(arrayOfByte, paramString);
     } catch (UnsupportedEncodingException localUnsupportedEncodingException) {
       throw new IllegalStateException(localUnsupportedEncodingException);
     }
   }
 }
